public class People {
    public int age;
    public String name;
    public People(){
        this("王宏伟",20);
        System.out.println("不带参数的构造方法");
    }
    public People(String name,int age){
        this.name = name;//使用this调用构造方法，且必须放在第一行。
        this.age = age;
        System.out.println(name+" "+age+" "+"\n"+"带两个参数的构造方法");
    }
    public void eat(){
        System.out.println(name+"在吃饭");
    }

    @Override
    public String toString() {   //右键+生成+toString
        return "People{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }
}